package LEETCODE2023.BISHUA100;

import java.util.*;

public class SolutionBM46 {
    public ArrayList<Integer> GetLeastNumbers_Solution(int[] input, int k) {
        Queue<Integer> queue = new PriorityQueue<>(k, Comparator.reverseOrder());

        ArrayList<Integer> ans = new ArrayList<>();
        if(input.length==0||k==0){
            return ans;
        }
        for (int i : input) {
            queue.offer(i);
            if (queue.size() > k ) {
                queue.poll();
            }
        }
        for (Integer i:queue
             ) {
            ans.add(i);
        }
        System.out.println(queue.toString());
        Collections.sort(ans);
        return ans;
    }
}
